<template>
  <div style="padding: 6px;">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" label-width="100px">
      <el-form-item label="日志时间开始" prop="beginDate">
        <el-date-picker style="width: 200px" v-model="queryParams.beginDate" type="date"></el-date-picker>
      </el-form-item>
      <el-form-item label="日志时间结束" prop="endDate">
        <el-date-picker style="width: 200px" v-model="queryParams.endDate" type="date"></el-date-picker>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="loadTbLog">查询</el-button>
      </el-form-item>
    </el-form>

    <el-table :data="tblogObj.list" border style="width: 100%">
      <el-table-column label="任务名称" prop="workTitle" width="300px"></el-table-column>
      <el-table-column label="更新条数" prop="uptatecount" width="120px"></el-table-column>
      <el-table-column label="日志时间" width="160px">
        <template v-slot="scope">
          <DateFormat :value="scope.row.logtime" :format="'YYYY-MM-DD HH:mm'"></DateFormat>
        </template>
      </el-table-column>
      <el-table-column label="日志内容" prop="neirong"></el-table-column>
    </el-table>
    <el-pagination class="center" background layout="total, prev, pager, next"
                   @current-change="loadTbLog" :total="tblogObj.total"
                   :current-page.sync="queryParams.pageNum" :page-size="queryParams.pageSize">
    </el-pagination>
  </div>
</template>

<script>
import request from '@/utils/request'
import dayjs from 'dayjs'

export default {
  data() {
    return {
      queryParams: {
        pageNum: 1,
        pageSize: 15,
        beginDate: dayjs().add(-7, 'day').format("YYYY-MM-DD"),
        endDate: dayjs().add(1, 'day').format("YYYY-MM-DD")
      },
      tblogObj: {}
    }
  },
  mounted() {
    this.loadTbLog()
  },
  methods: {
    loadTbLog() {
      request({
        url: '/tbwork/pagetblog',
        data: this.queryParams
      }).then(res => {
        const { data } = res
        this.tblogObj = data
      })
    },
  }
}
</script>
